﻿#include "guide.h"

#include "../../include/itframework.h"
#include "../../include/itlogger.h"
#include "../../include/itcommon.h"
extern "C" __declspec(dllexport) ITModelBase* GetInstance(ITFramework *pFrame)
{
    Guide *pGuide = Guide::GetInstance();
    pGuide->SetFramework(pFrame);
    return dynamic_cast<ITModelBase*>(pGuide);
}

void Guide::SetFramework(ITFramework *pFrm)
{
    m_pFramework = pFrm;
    m_pFramework->GetLogger(&m_pLogger);
    m_pFramework->GetCommon(&m_pcommon);
}

Guide::Guide()
{
    qDebug() << "Guide::Guide()";
}

Guide::~Guide()
{
    qDebug() << "Guide::~Guide()";
}

T_BEGIN_MAP(Guide)
    T_HANDLER(UI_GUIDE_request_CMD_ID,OnRequest,TUIGUIDE_request_Param,TUICONSULTANT_reply_Param)
T_END_MAP

void Guide::OnRequest(TUIGUIDE_request_Param *pInArgs, TUICONSULTANT_reply_Param *pOutArgs)
{
    qDebug() << "Guide::OnRequest InArg=" << pInArgs->send << "thread id=" << QThread::currentThreadId();
    QString szReply = QString("recv %1. reply: hello I'm Guide OnRequest").arg(pInArgs->send);
    if(NULL != pOutArgs)
        m_pcommon->copystru8(szReply.toUtf8().data(),pOutArgs->sendReply,sizeof(pOutArgs->sendReply));
}
